Contents | Index | < Browse | Browse >

LETTERatolULETTER Converts an ASCII string into a long integer.

Overview
#include <stdlib.h>

z = atol(s);

long z;
const char *s;

Portability
ANSI

Description
"atol" converts an ASCII string consisting of decimal numbers to its appropiate long integer value. Just like "atoi", "atol" is also a simplified version and equals "strtol(string, 0, 10)".
The ASCII string must have the form:
[ws][sign]digits
where ws stands for any number of whitespaces (plain spaces and tabs), sign is either '+' or '-' and digits means a sequence of numbers between 0 and 9. All elements within "[]" brackets are optional. This function does not check for integer overflow.

Returns
This function returns the long integer value if the ASCII string could be converted successfully and 0 otherwise.

See also
atof , atoi , strtod , strtol